import { REQUEST_STATUS } from '../lib/enum/STATUS_CODE'
import { ApiResponse } from '../lib/class/Response'
import { LatencySimulator } from './LatencySimulator'

export let MenuQuery = function (u, m) {
  if (!u || !m) {
    return new ApiResponse([], REQUEST_STATUS.REQUEST_ERROR)
  }
  switch (m) {
    case 'header-start':
      LatencySimulator.AsyncSleep(3000)
      return new ApiResponse(
        [
          { index: 0, name: '工作台', routerPath: '/workbench' },
          { index: 1, name: '数据', routerPath: '/data' },
          { index: 2, name: '报表', routerPath: '/report' },
          { index: 3, name: '受众', routerPath: '/audience' },
          { index: 4, name: '营销', routerPath: '/marketing' },
          { index: 5, name: '实验室', routerPath: '/lab' }
        ],
        REQUEST_STATUS.REQUEST_SUCCESS
      )
    case 'header-end':
      return new ApiResponse(
        [{ index: 0, name: '收藏夹', routerPath: '/' }],
        REQUEST_STATUS.REQUEST_SUCCESS
      )
    case 'data':
      return new ApiResponse(
        [
          {
            index: 0,
            name: '数据源',
            icon: 'el-icon-menu',
            routerPath: 'datasource'
          },
          {
            index: 1,
            name: '数据集',
            icon: 'el-icon-menu',
            routerPath: 'dataset'
          }
        ],
        REQUEST_STATUS.REQUEST_SUCCESS
      )
    case 'dashboard':
      return new ApiResponse(
        [
          {
            index: 0,
            name: '看板',
            icon: 'el-icon-menu',
            routerPath: 'dashboard'
          },
          { index: 1, name: '图表', icon: 'el-icon-menu', routerPath: 'chart' }
        ],
        REQUEST_STATUS.REQUEST_SUCCESS
      )
    default:
      return new ApiResponse()
  }
}
